L = list(range(1, 11))
print(L)

L1 = []
for i in L:
    L1.append(i * i)
print(L1)

L2 = [i * i for i in L]
print(L2)

L3 = [i * i for i in L if i % 2 == 0]
print(L3)

# test,,,for 循环后 只能有一个 if 条件，，，如果要if-else, 在一个列表生成式中，for前面的if ... else是表达式，而for后面的if是过滤条件，不能带else

L1 = ['Hello', 'World', 18, 'Apple', None]
L2 = [s.lower() for s in L1 if isinstance(s, str)]
print(L2)

L3 = [s.lower() if isinstance(s, str) else None for s in L1]
L3 = [item for item in L3 if item is not None]
print(L3)
